<template>
  <div>
  <el-card class="box-card">
    <div slot="header" class="clearfix">
      <span>新增加班申请</span>
      <el-button @click="backUserList" style="float: right; padding: 3px 0" type="text">返回我的加班记录</el-button>
    </div>
    <div>
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="开始时间" prop="form.startTime">
          <template>
            <el-time-picker
                    v-model="form.startTime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    :picker-options="{
                        format: 'yyyy-MM-dd HH:mm:ss'
                      }"
                    placeholder="开始时间">
            </el-time-picker>
          </template>
        </el-form-item>
        <el-form-item label="结束时间" prop="form.endTime">
          <template>
            <el-time-picker
                    v-model="form.endTime"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    :picker-options="{
                        format: 'yyyy-MM-dd HH:mm:ss'
                      }"
                    placeholder="结束时间">
            </el-time-picker>
          </template>
        </el-form-item>
        <el-form-item label="原因" prop="form.reason">
          <div class="block" style="width: 500px">
            <el-input style="width: 300px" v-model="form.reason"
                      type="textarea"
                      :rows="2"></el-input>
          </div>
        </el-form-item>
      </el-form>
      <el-button @click="submit" type="primary">提交加班申请</el-button>
    </div>
  </el-card>

</div>
</template>

<script>
  import { getAllDepartment, delDepartment } from "../../network/Department"
  import {delUser, getUser} from "../../network/UserInfo";
  import {editOverTime} from "../../network/Overtime";
  export default {
    name: "OvertimeEdit",
    data() {
      return {
        departmentIds:[],
        form: {
        }
      }
    },
    methods: {
      getOverTime() {
        this.form = this.$store.state.overtimeData
        console.log(this.form)
      },

      backUserList() {
        this.$router.back(1)
      },
      submit() {
        editOverTime(this.form, this.form.id).then(res => {
          this.$message.success('修改日报成功')
          setTimeout(() => {
            this.$router.back(1)
          }, 500)
        }, err => {
          this.$message.error('修改日报失败，请检查错误')
        })
      }
    },
    created() {
      this.getOverTime()
    }
  }
</script>

<style scoped>

</style>
